package org.example.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import static org.example.enums.ResultCode.FAIL;
import static org.example.enums.ResultCode.SUCCESS;


/**
 * 工具类，用于包装获取到的data
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {
    private Integer code; //StatusCode
    private Boolean success;
    private Object data; //查询到的结果
    private String msg; //信息

    public static Result ok(Object data){
        return new Result(SUCCESS.code,true,data,"success");
    }
    public static Result fail(String msg){
        return new Result(FAIL.code,false,null,msg);
    }

}
